class TempExaminationResoult < ActiveRecord::Base
  has_many :param_resoults
  belongs_to :order_examination

  after_update :save_params

  def param_resoult_attributes=(param_resoult_attributes)
    param_resoult_attributes.each do |attributes|
      if attributes[:id].blank?
        param_resoults.build(attributes)
      else
        param = param_resoults.detect { |t| t.id == attributes[:id].to_i }
        param.attributes = attributes
      end
      
    end
  end

  def save_params
    param_resoults.each do |t|
      t.save(false)
    end
  end
  
end
